package net.comm.param.db;


import java.sql.ResultSet;
import java.sql.SQLException;


import net.comm.param.bean.BaseProperty;
import net.comm.util.StringUtil;

import org.apache.log4j.Logger;
import org.sakaiproject.db.api.SqlReader;

public class DbPropertyService implements SqlReader
{

	static Logger logger = Logger.getLogger(DbPropertyService.class.getName());

	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{
			
			int  	assortID = result.getInt(1);
			int  	propID = result.getInt(2);
			String  propname = StringUtil.getValue(result.getString(3));
			String  assortname = StringUtil.getValue(result.getString(4));
			int  	parentID = result.getInt(5);
			int  	disNO = result.getInt(6);
			int	  	exichiflag = result.getInt(7);
			int  	userID = result.getInt(8);
			String  mTime = StringUtil.getValue(result.getString(9));

			// create the Resource from these fields
			return new BaseProperty( assortID,  propID,  propname, assortname,  parentID,  disNO, 
					exichiflag, userID,  mTime);
		}
		catch (SQLException e)
		{
			logger.error("读取表数据持久层失败！");
			return null;
		}
		
	}
}
